package com.jwsoft.manager.core.dao.service.impl;

import com.bifang.module.base.common.util.CommonSecureUtil;
import com.jwsoft.manager.core.dao.model.EduhLivePlace;
import com.jwsoft.manager.core.dao.mapper.EduhLivePlaceMapper;
import com.jwsoft.manager.core.dao.service.EduhLivePlaceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * 居住证历史表服务实现类
 *
 * @author zhiyuan
 * @since 2023-09-13
 */
@Service
public class EduhLivePlaceServiceImpl extends ServiceImpl<EduhLivePlaceMapper, EduhLivePlace> implements EduhLivePlaceService {

    @Override
    public void encrypt(EduhLivePlace eduhLivePlace) {
        if (StringUtils.isNotBlank(eduhLivePlace.getSfzh())) {
            eduhLivePlace.setSfzh(CommonSecureUtil.sm4Encrypt(eduhLivePlace.getSfzh()));
        }
        if (StringUtils.isNotBlank(eduhLivePlace.getXm())) {
            eduhLivePlace.setXm(CommonSecureUtil.sm4Encrypt(eduhLivePlace.getXm()));
        }
        if (StringUtils.isNotBlank(eduhLivePlace.getJzdz())) {
            eduhLivePlace.setJzdz(CommonSecureUtil.sm4Encrypt(eduhLivePlace.getJzdz()));
        }
    }

    @Override
    public void decrypt(EduhLivePlace eduhLivePlace) {
        if (StringUtils.isNotBlank(eduhLivePlace.getSfzh())) {
            eduhLivePlace.setSfzh(CommonSecureUtil.sm4Decrypt(eduhLivePlace.getSfzh()));
        }
        if (StringUtils.isNotBlank(eduhLivePlace.getXm())) {
            eduhLivePlace.setXm(CommonSecureUtil.sm4Decrypt(eduhLivePlace.getXm()));
        }
        if (StringUtils.isNotBlank(eduhLivePlace.getJzdz())) {
            eduhLivePlace.setJzdz(CommonSecureUtil.sm4Decrypt(eduhLivePlace.getJzdz()));
        }
    }
}
